package factories;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * 创建SqlSessionFactory对象的工厂
 *   -- 实例方法工厂 (方法是非静态的，需要通过工厂对象调用)
 */
public class SSFFactory {

    public SqlSessionFactory ssf() throws IOException {
        InputStream is = Resources.getResourceAsStream("mybatis.xml");
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);

        return factory;
    }
}
